package org.moyrax.nereyda.services.factory
{
	import org.moyrax.nereyda.services.template.IServiceEvent;
	import org.moyrax.nereyda.services.template.IServiceObject;
	
	import flash.net.getClassByAlias;
	
	public class EventFactory
	{	
		public static function createInstance( event:String, object:IServiceObject ):IServiceEvent
		{
			var eventClass :Class = getClassByAlias(event);
			var eventInst  :IServiceEvent = new eventClass(object);
			
			return(eventInst);
		}

		public function getEventName( event:Class ):String
		{
			return( ClassFactory.getInstance().getClassAlias(event) );
		}
		
		// Devuelve una instancia única de la clase.
		//
		private static var instance :EventFactory = null;
		
		public static function getInstance():EventFactory
		{
			if ( instance == null )
				instance = new EventFactory();
			
			return( instance );
		}
	}
}